home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
1,000 Game Levels 2
/
1,000 Game Levels 2.iso
/
DOSARC
/
BOWHUNT.ZIP
/
GAME.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-05-21
|
7KB
|
265 lines
Program Game;
Uses Dos, Crt, Graph, VGA256;
Var
i : integer; {used for looping}
regs : registers; {define interupt registers}
x,y : integer; { horiz. and vert. position}
Gd, Gm : integer;
OldPattern : FillPatternType;
h, m, s, hund : Word; {hours minutes seconds hundreds for timing routine}
origsec : word; {original second}
orighund : word;
button : integer; {mouse button state}
Score : integer; {current score}
hits : integer; {current amount of hits}
shotcolor : integer; {colour of pixel shot}
MissFlag : boolean; {if miss is true}
ScoreFile : Text; {high score list text file type}
Name : Array[1..11] of String; {player list}
PlayerScore : Array [1..11] of integer; { high score list }
Player : string; {acutal player name}
noshots : integer;
Const
FileName = 'score.txt';
Procedure Title;
begin
Writeln ('Shoot V1.0');
Writeln ('Turbo Pascal 7.0 VGA256.TPU ASSEMBLY LANGUAGE CODE ALSO');
Writeln ('Mouse driver (Int 33h) used');
Writeln ('Experimental version only');
readln;
end;
Procedure MakeScore; {save score to disk}
var
i : integer; {temp variable for loop}
Begin
Assign (ScoreFile, filename); {assign score as score.txt}
ReWrite (ScoreFile);
i := 1;
While I<=10 do begin {loop and write}
Writeln (Scorefile, Name[i]);
Writeln (Scorefile, PlayerScore[i]);
i:=i+1;
end;
Close (Scorefile);
end;
Procedure ReadScore; {input original high score list}
var i : integer;
Input : Text;
Begin
assign ( Input, filename );
Reset (Input);
i := 1;
while I<=10 do begin
Readln (Input, Name[i]);
Readln (Input, PlayerScore[i]);
i:=i+1;
end;
End;
Procedure ReplaceScore;
var num : integer;
i : integer;
flag : boolean;
begin
Flag := False;
num := 1; {num = number of score which is lower than player score}
while flag = false do Begin
if PlayerScore[num]> Score then num:=num+1
else flag := True;
end;
if num<11 then for i:=9 downto num do begin;
PlayerScore[i+1] := PlayerScore[i];
Name[i+1] := name[i];
end;
if num<11 then
begin;
TextColor(LightGreen);
GotoXY(13,7);
writeln('Congratulations ! You have entered the hall of fame');
for i:=100 to 300 do
begin
sound (i);
delay (10);
end;
nosound;
GotoXY(25,8);
Write ('Please enter your name : ');
Read (Player);
GotoXY(25,8);
ClrEol;
end;
if num<11 then PlayerScore[num]:=Score;
if num<11 then Name[num]:=Player; {actual player}
TextColor(LightMagenta);
GotoXY(30,8);
writeln ('High Score List');
TextColor(Yellow);
for i:=1 to 10 do begin
GotoXY(15,12+i);
if i=10 then GotoXY(14,12+i);
writeln (i,'. ',Name[i]);
GotoXY(55,12+i);
Writeln (PlayerScore[i]);
end;
end;
Procedure MouseOn; Assembler;
asm
mov ax,1;
int 33h;
end;
Procedure MouseOff; Assembler;
asm
mov ax,2;
int 33h;
end;
Procedure TestMouse;
begin
regs.ax := 0;
intr ($33,regs);
if regs.ax = 0 then Halt(2);
end;
Procedure SetMouse (X : word; Y : word);
begin
regs.ax := 4;
regs.cx := X;
regs.Dx := y;
intr ($33,regs);
end;
Procedure FilledCircle (X : integer; Y:integer; radius : integer; FillColor: Word);
begin
SetColor (FillColor);
Circle (X,y,radius);
SetFillPattern (OldPattern, FillColor);
FloodFill (X,y, FillColor);
end;
Procedure Init;
var
radius : integer;
begin
randomize;
Gd := Detect;
InitGraph(Gd, Gm, ' ');
if GraphResult <> grOk then
Halt(1);
cleardevice;
GetFillPattern (OldPattern);
FilledCircle (320,240, 100, Yellow);
FilledCircle (320,240, 80, Green);
FilledCircle (320,240, 60, Blue);
FilledCircle (320,240, 40, Brown);
FilledCircle (320,240, 20, Red);
GetTime (h,m,origsec,orighund);
SetTime (h,m,0,0);
Origsec := 0;
orighund := 0;
TestMouse;
MouseOn;
OutTextXY (10,50,'Time :');
end;
procedure ShowTime;
var
temp : string;
timestring : string;
begin
SetColor (Black);
OutTextXY (80,50,timestring);
GetTime (h,m,s,hund);
Str (hund,temp);
Timestring := temp;
SetColor (green);
if s = 1 then begin
button :=1 ;
timestring := 'Miss';
MissFlag := True;
end else MissFlag := False;
OutTextXY (80,50,timestring);
end;
Procedure GetMouse;
begin
regs.ax := 3;
intr ($33,regs);
X:= regs.cx;
y:= regs.dx;
button :=regs.bx;
end;
Procedure CalculateScore;
begin
if shotColor <> black then if MissFlag = False then
begin
hits:=hits+1;
if shotColor = Red then score :=score + 8*2*(100-hund);
if shotColor = Brown then score :=score + (6*2*(100-hund));
if shotColor = Blue then score :=score + (4*2*(100-hund));
if shotColor = Green then score :=score + (2*2*(100-hund));
if shotColor = Yellow then score :=score + (1*2*(100-hund));
end;
end;
Procedure ClearTime;
begin
SetTime (h,m,0,0);
end;
Procedure DoShots;
begin
mouseoff;
SetMouse (random(640),random(480));
mouseon;
cleartime;
repeat
GetMouse;
ShowTime;
until (button = 1);
Mouseoff;
ShotColor := GetPixel(x,y);
CalculateScore;
filledcircle (x,y,2,white);
MouseON;
end;
begin
ReadScore;
for noshots {no of shots } := 1 to 20
do begin
init;
DoShots;
delay (100);
end;
initText;
TextColor(Lightblue);
GotoXY(30,3);
writeln('Total score : ',score);
GotoXY(15,5);
TextColor(Red);
writeln('Out of a possible ',noshots,' shots, a total of ',hits,' scored!');
ReplaceScore;
MakeScore;
mouseoff;
end.